package com.wing.product.service;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.common.utils.JsonResult;
import com.wing.product.dao.WarehouseProcessingDescriptionDao;
import com.wing.product.model.entity.WarehouseProcessingDescription;
import com.wing.product.model.entity.WarehouseProductMark;
import com.wing.product.model.response.WarehouseProcessingDescriptionVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class WarehouseProcessingDescriptionServiceImpl extends ServiceImpl<WarehouseProcessingDescriptionDao, WarehouseProcessingDescription> implements WarehouseProcessingDescriptionService{

    @Override
    public Page<WarehouseProcessingDescriptionVO> pageList4app(Page page, Map<String, Object> params) {
        List<WarehouseProcessingDescriptionVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public JsonResult saveWarehouseProcessingDescription(WarehouseProcessingDescription warehouseProcessingDescription){

        if (ObjectUtil.isNotEmpty(warehouseProcessingDescription)){
            this.baseMapper.insert(warehouseProcessingDescription);
            return JsonResult.success("添加成功");
        }else {
            return JsonResult.fail("添加失败");
        }
    }

    @Override
    public JsonResult deleteWarehouseProcessingDescription(Long id){

        if (ObjectUtil.isNotEmpty(id)){
            WarehouseProcessingDescription warehouseProcessingDescription = this.getById(id);
            warehouseProcessingDescription.setIsDeleted(true);
            baseMapper.updateById(warehouseProcessingDescription);
            return JsonResult.success("删除成功");
        }else {
            return JsonResult.fail("删除失败");
        }
    }

    @Override
    public JsonResult updateWarehouseProcessingDescription(WarehouseProcessingDescription warehouseProcessingDescription){
        if (ObjectUtil.isNotEmpty(warehouseProcessingDescription)){
            baseMapper.updateById(warehouseProcessingDescription);
            return JsonResult.success("修改成功");
        }else {
            return JsonResult.fail("修改失败");
        }
    }
}
